import Vue from 'vue'
import App from './App'
import api from '@/common/http/'
import store from './store'
import {  
	mapState
} from 'vuex';
Vue.config.productionTip = false
/**
 * 格式化日期时间
 * 
 * @param format
 * @returns
 */
Date.prototype.format = function(format) {
	if (isNaN(this.getMonth())) {
		return '';
	}
	if (!format) {
		format = "yyyy-MM-dd hh:mm:ss";
	}
	var o = {
		/* month */
		"M+" : this.getMonth() + 1,
		/* day */
		"d+" : this.getDate(),
		/* hour */
		"h+" : this.getHours(),
		/* minute */
		"m+" : this.getMinutes(),
		/* second */
		"s+" : this.getSeconds(),
		/* quarter */
		"q+" : Math.floor((this.getMonth() + 3) / 3),
		/* millisecond */
		"S" : this.getMilliseconds()
	};
	if (/(y+)/.test(format)) {
		format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
	}
	for ( var k in o) {
		if (new RegExp("(" + k + ")").test(format)) {
			format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
		}
	}
	return format;
};
App.mpType = 'app'
Vue.prototype.$api = api
Vue.prototype.$store = store
Vue.mixin({
	data:function(){
		return {
			shareTitle:"快来看看吧！"
		}
	},
	computed: {  
		...mapState(['openid','userInfo'])  
	},
	filters:{
		formatDate:function(time,format) {
			return new Date(time).format(format);
		}
	},
	methods:{
		getShareOjbect:function(){
			return {
			  path: '/pages/index/index?fatherId='+this.userInfo.id
			}
		}
	}
})
const app = new Vue({
    ...App
})
app.$mount()

